package com.wlc.rabbitmq.directqueue;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 王立朝
 * @description Direct 模式就是指定队列模式
 * @date 2021-12-15 09:20:16
 */
@Component
public class DirectProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendMessageA() {

            for (int i = 0; i < 50; i++) {
                String message = "路由模式--routingKey=update消息" + i;
                System.out.println("我是生产信息的：" + message);
                rabbitTemplate.convertAndSend("directExchange", "update", message);
            }


    }

    public void sendMessageB() {
        for (int i = 0; i < 5; i++) {
            String message = "路由模式--routingKey=add消息" + i;
            System.out.println("我是生产信息的：" + message);
            rabbitTemplate.convertAndSend("directExchange", "add", message);
        }
    }

}
